import os
import cPickle as pickle

def pickle_data(data, filepath, protocol = 1):
	file_object = open(filepath, "wb")
	pickle.dump(data, file_object, protocol)
	file_object.close()

def unpickle_data(filepath):
	if os.path.isfile(filepath):
		file_object = open(filepath, "rb")
		data = pickle.load(file_object)
		file_object.close()
		return data